{include_core file="m/lib/header.html" type="register" title="用户注册" }
<div class="register">
    <div class="input-box">
      <form action="{AnUrl('user/register/save')}" method="post" id="js_register_m">
        <p class="txt-wrap"><input type="text" name="username" id="js_usernameM" placeholder="用户名"/></p>
        <p class="txt-wrap"><input type="text" placeholder="手机号码" name="mobile" id="js_mobileM"/></p>
        <p class="txt-wrap"><input type="text" placeholder="验证码" name="code" id="js_codeM"/><a href="javascript:void(0);" class="get-btn" id="getCode" value="on">获取验证码</a></p>
        <p class="txt-wrap"><input type="password" placeholder="密码" name="password" id="js_pwM"/></p>
        <div class="bottom clearfix"><label><input type="checkbox" id="isRead">我已阅读并接受《NBD服务协议条款》</label><a href="{AnUrl('user/login')}" class="hased">已有账号</a></div>
        <div class="btns"><a href="javascript:void(0);" id="register-mobile" class="btn ">注册</a></div><!--disabled-->

      </form>
      <p class="lx-login"><a href="{AnUrl('openapi/lenovo/index')}">联想通行证登录</a></p>
      <div class="social">
        <div class="top"><span>合作账号登录</span></div>
        <div class="social-icons">
          <a href="{AnUrl('openapi/sinaweibo/index')}" class="icon1"></a>
          <a href="{AnUrl('openapi/qqconnect/login')}" class="icon2"></a>
          <a href="{AnUrl('openapi/baiduconnect/login')}" class="icon3"></a>
          <a href="{AnUrl('openapi/weixin/index/login')}" class="icon4"></a>
        </div>
      </div>
    </div>
</div>
<script type="text/javascript">
function FinishRegister(){
        //alert("click ok");
  window.ceyes.Finished();

}
$(function(){
  $('#register-mobile').click(function(){
    //验证用户名
    var username = $.trim($('#js_usernameM').val());
    var userLen  = getStringLen(username);
    if(username == '') {
      mobileShowMsg('用户名不能为空');
      return ;
    }
    if(checkStr(username, 'mail')) {
      mobileShowMsg('用户名不能为邮箱！');
      return ;
    }
    if(userLen < 6 || userLen > 20) {
      mobileShowMsg('用户名应在6个到20个字符之间');
      return ;
    }
    if(!checkStr(username, 'name')) {
      mobileShowMsg('用户名格式不正确');
      return ;
    }
    if(is_number(username)) {
      mobileShowMsg('用户名不能为纯数字');
      return ;
    }

    //验证手机号
    var mobile = $.trim($('#js_mobileM').val());
    if(mobile == '') {
      mobileShowMsg('手机号不能为空');
      return ;
    }
    if(!checkStr(mobile, 'mobile')) {
      mobileShowMsg('手机号格式不正确');
      return ;
    }

    //验证手机验证码
    var code = $.trim($('#js_codeM').val());
    if(mobile == '') {
      mobileShowMsg('手机号不能为空');
      return ;
    }
    if(!checkStr(mobile, 'mobile')) {
      mobileShowMsg('手机号格式不正确');
      return ;
    }
    if(code == '') {
      mobileShowMsg('验证码不能为空');
      return ;
    }
    //验证密码
    var pw       = $.trim($('#js_pwM').val());
    if(pw == '') {
      mobileShowMsg('密码不能为空');
      return ;
    }
    if(getStringLen(pw) < 6) {
      mobileShowMsg('密码最少要6位字符');
      return ;
    }
    if(getStringLen(pw) >= 20) {
      mobileShowMsg('密码最多20位字符');
      return ;
    }
    if(!$('#isRead').is(':checked')) {
      mobileShowMsg('请先同意《NBD服务协议条款》！');
      return ;
    }
    $.post(
      "{AnUrl('user/register/save')}",
      { 'username':username, 'mobile':mobile, 'code':code, 'password':pw },
      function(data){
        if(data.info == 'ok') {
          mobileShowMsg('注册成功，跳转中……');
          FinishRegister();
        } else {
          mobileShowMsg(data.msg);
        }
      },'json');
  });

  //获取验证码
  $('#getCode').click(function(){
    //验证用户名
    var username = $.trim($('#js_usernameM').val());
    var userLen  = getStringLen(username);
    if(username == '') {
      mobileShowMsg('用户名不能为空');
      return ;
    }
    if(checkStr(username, 'mail')) {
      mobileShowMsg('用户名不能为邮箱！');
      return ;
    }
    if(userLen < 6 || userLen > 20) {
      mobileShowMsg('用户名应在6个到20个字符之间');
      return ;
    }
    if(!checkStr(username, 'name')) {
      mobileShowMsg('用户名格式不正确');
      return ;
    }
    if(is_number(username)) {
      mobileShowMsg('用户名不能为纯数字');
      return ;
    }
    $.post(
        "{AnUrl('user/register/ajax_username')}",
        { username:username },
        function(data){
          if(data.info == 'error') {
            mobileShowMsg(data.msg);
            return;
          }
        },'json');

    //验证手机号
    var mobile = $.trim($('#js_mobileM').val());
    if(mobile == '') {
      mobileShowMsg('手机号不能为空');
      return ;
    }
    if(!checkStr(mobile, 'mobile')) {
      mobileShowMsg('手机号格式不正确');
      return ;
    }
    $.post(
        "{AnUrl('user/register/ajax_mobile')}",
        { mobile:mobile },
        function(data) {
          if(data.info == 'error') {
            mobileShowMsg(data.msg);
            return;
          } else {
            if($('#getCode').attr('value') == 'on') {
              var time = 59;
              $('#getCode').html(time).attr('value', 'off');
              var Timer=setInterval(function(){
                if(time > 0){
                  time--;
                  $('#getCode').html(time).attr('value', 'off');
                } else {
                  $('#getCode').html('获取验证码').attr('value', 'on');
                  clearInterval(Timer);
                }
              },1000);
            $.post(
                "{AnUrl('user/register/sendRegsms')}",
                { 'mobile':mobile, 'send_type':'register' },
                function(data){
                  if(data.info == 'error') {
                    mobileShowMsg(data.msg);
                  }
                },'json');
            }
          }
        },'json');

  });
});
</script> 
{include_core file="m/lib/footer.html" type="register" title="用户注册" } 
